package edu.xhxy;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;


public class TokenizerMapper extends Mapper<Object, Text,Text, IntWritable> {
    @Override
    protected void map(Object key, Text value, Mapper<Object, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        super.map(key, value, context);
        String[] words = value.toString().split(" ");
        for(String w:words){
            Text tw = new Text(w);
            IntWritable i = new IntWritable(1);
            context.write(tw,i);
        }
    }
}
